package top.chendawei.main.facade;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.hanyun.oss.service.HanyunLoginUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;

@Slf4j
@Service
public class LoginUserseviceImpl implements HanyunLoginUserService {

    @Override
    public Map<String, Object> loginCheck(JSONObject body, String accessToken) throws UnsupportedEncodingException {
        log.info("body:{}", body);
        String realName = body.getString("realName");
        String loginName = body.getString("loginName");
        // 登陆后根据token获取用户信息-----推荐对接系统若无此用户做用户注册，并赋予相关基本角色

        //以下为模拟操作
        Map<String, Object> data = Maps.newHashMap();
        data.put("token", accessToken);
        data.put("realName", URLEncoder.encode(realName, "UTF-8"));
        data.put("loginName", loginName);
        return data;
    }
}
